package com.kadron.service;

import com.kadron.entity.ConfirmKey;

public class CommonUserService {

	private static long counter = 1;
	private static final Object LOCK_OBJECT = new Object();
	
	public static void initCounter(long initValue) {
		synchronized (LOCK_OBJECT) {			
			CommonUserService.counter = initValue;
		}
	}
	
	public static long getCounter() {
		synchronized (LOCK_OBJECT) {			
			counter++;
			return counter;
		}
	}
	
	public static String getConfirmationLink(ConfirmKey confirmKey, String contextPath) {
		StringBuilder builder = new StringBuilder(contextPath);
		builder.append("/k_user_confirmation.k?");
		builder.append("key="+confirmKey.getConfirmKey());
		builder.append("&");
		builder.append("pid="+confirmKey.getUser().getId());
		return builder.toString();
	}
	
}
